package com.sisgh.jefdv1.cmd.command.has.arg.argument.impl;

import com.sisgh.jefdv1.cmd.command.has.arg.argument.AbstractArgument;
import com.sisgh.jefdv1.cmd.command.has.arg.argument.function.format.MarkerChecker;
import com.sisgh.jefdv1.cmd.command.has.arg.argument.function.format.impl.ArgMarker;
import com.sisgh.jefdv1.cmd.command.has.arg.argument.properties.ArgumentProperties;

public class OptionMarkerArgument extends AbstractArgument {

    public static final ArgMarker MARKER = new ArgMarker("--", "-");

    public static MarkerChecker checker() {
        return MARKER;
    }

    public OptionMarkerArgument(ArgumentProperties properties) {
        super(properties);
    }

    public OptionMarkerArgument(String longName, String shortName, boolean required) {
        super(longName, shortName, required);
    }

    private boolean longMatched(String arg) {
        return arg.equals(MARKER.longMarker() + longName);
    }

    private boolean shortMatched(String arg) {
        return arg.equals(MARKER.shortMarker() + shortName);
    }

    @Override
    public boolean matches(String arg) {
        String lowerArg = arg.toLowerCase();
        return longMatched(lowerArg) || shortMatched(lowerArg);
    }

    @Override
    public String longName() {
        return MARKER.longMarker() + longName;
    }

    @Override
    public String shortName() {
        return MARKER.shortMarker() + shortName;
    }
}
